package StudyCode.summary.myfile;

import java.io.IOException;
import java.nio.file.*;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class FilterByPathMatcher {
	public static void main(String[] args) {
		Path directory = Paths.get("D:\\jdk1.7.0_80\\bin");
		PathMatcher pathMatcher = FileSystems.getDefault().getPathMatcher("glob:java?.exe");
		try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(directory, "java*.exe")) {
			for (Path file : directoryStream) {
				if (pathMatcher.matches(file.getFileName())) {
					System.out.println(file.getFileName());
				}
			}
		} catch (IOException | DirectoryIteratorException ex) {
			ex.printStackTrace();
		}

	}
}
